<template>
  <div id="app">
    <!--<input type="text" v-model="count">-->
    <div class="count" @click="add">{{count}}</div>
  </div>
</template>

<script>
export default {
  name: 'App',
  computed:{
    count:{
      get(){return this.$store.state.count}
    }
  },
  methods:{
    add(){
      //修改仓库中的数据  不能直接修改
      // this.$store.state.count++

      //调用仓库中的mutation进行修改(提交mutation)
      // this.$store.commit("add",{step:2,flag:"xxx"})

      //如果有异步逻辑
      // 我们希望组件上通过 转发action 进而提交muation 进而修改state
      this.$store.dispatch("add",{step:2,flag:"xxx"})
    }
  }
}
</script>

<style scoped>
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
  }

  .count{
    width: 100px;
    height: 100px;
    background: pink;
    text-align: center;
    line-height: 100px;
    border-radius: 50%;

    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto;

    font-size: 30px;
    color: red;
  }
</style>
